home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 418 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.1 KB  |  65 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: jpotter@falcon.lhup.edu (John E. Potter)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Name lookup for base class (aka strange thing)
  5. Date: 20 Feb 1996 10:46:18 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <9602181725.AA26252@falcon.lhup.edu>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Sun, 18 Feb 1996 12:25:02 -0500
  11. X-Newsreader: TIN [version 1.2 PL2]
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMSoXBky4NqrwXLNJAQGq8QH/eEHrBAFoiNieb/SbSh8tSDwHJBolQQsv
  14.     zi6IBW39HLU/BjPRsvN1ZWjzv47je4Mr4ZRGncCStjrLEZmgl2acYA==
  15.     =l7pX
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. "Problem" duplicated with IBM xlC.
  19.  
  20. class B {
  21.     protected :
  22.         struct B1 {
  23.                 int i;
  24.             };
  25.     };
  26. class D : public B {
  27.     friend struct D1;
  28.     public :
  29.         D::B1 b1; // ok B::B1 is accessable to D.
  30.     protected :
  31.         struct D1 : public D::B1 {
  32.                 // error: protected member "B::B1" cannot be accessed.
  33.             };
  34.     };
  35. D::B1 b1; // error: protected member "B::B1" cannot be accessed.
  36. D d;
  37. int x(d.b1.i);  // ok d.b1 is public and so is d.b1.i.
  38.  
  39.  
  40. ARM pg187: "Member functions of a nested class have no special access to
  41. members of an enclosing class; they obey the usual access rules".
  42.  
  43. The nested class declaration has no more right to inherit from the
  44. protected types of the enclosing class than do its member functions
  45. to access the protected members.  Although not explicitly stated, this
  46. seems consistent.  Expert opinion appreciated.
  47.  
  48. For a concrete example, consider Stroustrup, "The C++ Programming Language",
  49. Section 8.3.  Let B == slist_base, B1 == slink, D == Slist, D1 = Tlink.
  50. In that case, it is D : private B and the error messages change to
  51. private member "B::B1".
  52.  
  53. It seems like a good idea to move the links into the protected areas of
  54. the lists; however, it is not possible.
  55.  
  56. Enjoy,
  57. John
  58. ---
  59. [ To submit articles: Try just posting with your newsreader.  If that fails,
  60.                       use mailto:std-c++@ncar.ucar.edu
  61.   FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  62.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  63.   Comments? mailto:std.c++-request@ncar.ucar.edu 
  64. ]
  65.